package com.qhhc.hospital.controller;

import com.qhhc.hospital.entity.DoctorUser;
import com.qhhc.hospital.service.IDoctorUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DoctorUserController {
    @Autowired
    IDoctorUserService doctorUserService;

    @RequestMapping("/insertDoctorUser")
    public String insertDoctorUser(@RequestBody DoctorUser doctorUser){
        doctorUserService.insert(doctorUser);
        return "success";
    }

    @RequestMapping("/getAllDoctorUsers")
    public List<DoctorUser> getAllDoctorUsers(){
        List<DoctorUser> doctorUsers = doctorUserService.selectAll();
        return doctorUsers;
    }

    @RequestMapping("/getDoctorUser/{dId}")
    public DoctorUser getDoctorUserById(@PathVariable("dId") Integer dId){
        return doctorUserService.selectById(dId);
    }
    
    @RequestMapping("/getDoctorUserBySection/{dSection}")
    public List<DoctorUser> getDoctorUserBySection(@PathVariable("dSection") String dSection){
        return doctorUserService.selectBySection(dSection);
    }

    @RequestMapping("/updateDoctorUser")
    public String updateDoctorUser(@RequestBody DoctorUser doctorUser){
        doctorUserService.update(doctorUser);
        return "success";
    }

    @RequestMapping("/deleteDoctorUser/{dId}")
    public String deleteDoctorUser(@PathVariable("dId") Integer dId){
        doctorUserService.delete(dId);
        return "success";
    }
} 